package com.itheima.dao;

import com.github.pagehelper.Page;
import com.itheima.pojo.CheckGroup;
import com.itheima.pojo.Setmeal;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Select;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

public interface SetmealDao {

    public void add(Setmeal setmeal);

    public void setCheckGroupAndCheckItem(HashMap<String, Integer> map);

    public Page<CheckGroup> findByCondition(String queryString);

    @Select("select * from t_setmeal where id=#{id}")
    public Setmeal findById(Integer id);

    @Select("select checkgroup_id from t_setmeal_checkgroup where setmeal_id=#{id}")
    public List<Integer> findCheckGroupIdsBySetmealId(Integer id);

    @Delete("delete from t_setmeal_checkgroup where setmeal_id = #{id}")
    public void deleteAssocication(Integer id);

    @Delete("delete from t_setmeal where id=#{id}")
    public void deleteById(Integer id);

    @Select("select count(*) from t_order where setmeal_id = #{setmeal_id}")
    public long findCountSetmealId(Integer id);

    public void edit(Setmeal setmeal);

    @Select("select * from t_setmeal")
    public List<Setmeal> findAll();

    public Setmeal findById4Detail(int id);

    @Select("select s.name ,COUNT(o.id) value from t_setmeal s , t_order o where s.id=o.setmeal_id group by s.name")
    public List<Map<String, Object>> findSetmealCount();
}
